package com.easywan.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.easywan.dao.ToolsCounterMapper;
import com.easywan.pojo.IResult;
import com.easywan.pojo.IResultSupport;
import com.easywan.service.IToolsCounterService;
import com.easywan.vo.ToolsCounter;

@Service("toolsCounterService")
public class ToolsCounterServiceImpl implements IToolsCounterService{
	@Autowired
	ToolsCounterMapper mapper;
	@Transactional
	public IResult add(String ip, String toolName) {
		ToolsCounter toolsCounter = new ToolsCounter();
		toolsCounter.setIp(ip);
		toolsCounter.setToolsName(toolName);
		Date date = new Date();
		toolsCounter.setCreatetime(date);
		toolsCounter.setModifytime(date);
		int addResult = mapper.add(toolsCounter);
		return IResultSupport.buildResult(
				addResult > 0 ? IResult.SUCCESS_CODE : IResult.FAILT_CODE, 
						"添加成功");
	}
	
}
